package com.yanqu.road.server.cmd.newmonopolymkt.office;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.newmonopolymkt.NewMonopolyMarketModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_NEW_MONOPOLY_MARKET_QUE_SHU_POINT_SYNC, desc = "榷署资源点同步")
public class NewMonopolyMarketQueShuPointSyncCmdFromCross implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage yanQuMessage) throws Exception {
        NewMonopolyMarketProto.NewMonopolyMarketQueShuPointSync.Builder sync = NewMonopolyMarketProto.NewMonopolyMarketQueShuPointSync.parseFrom(yanQuMessage.getBytes()).toBuilder();
        for (GamePlayer player : GamePlayerMgr.getAllOnlinePlayer()) {
            if(null != player.getModule(NewMonopolyMarketModule.class).userData){
                player.sendPacket(Protocol.U_NEW_MONOPOLY_MARKET_QUE_SHU_POINT_SYNC, sync);
            }
        }
    }
}
